<template>
    <div class='page-content'>
        <table-bar :showTop="true" :columns="columns" @changeColumn="changeColumn">
            <div slot="top">
                <el-form label-width="90px">
                    <el-row :gutter="20">
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="分期方式：">
                                <el-select v-model="enroll_type" style="width:100%" placeholder="请选择分期方式">
                                    <el-option label="全款" value="1"></el-option>
                                    <el-option label="普通分期" value="2"></el-option>
                                    <el-option label="报名(普通分期)" value="3"></el-option>
                                    <el-option label="报名(固定分期)" value="4"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="报考省：">
                                <el-select v-model="province_id" @change="getCityList" filterable style="width:100%" placeholder="报考省">
                                    <el-option v-for="(item,index) in provinceList" :label="item.name" :value="item.id" :key="index"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <template v-if="cityList.length > 0">
                            <el-col :xs="24" :sm="12" :lg="6">
                                <el-form-item label="报考市：">
                                    <el-select v-model="city_config_id" filterable style="width:100%" placeholder="报考市">
                                        <el-option v-for="(item,index) in cityList" :label="item.name" :value="item.id" :key="index"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </template>
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="类型：">
                                <el-select v-model="school_type_id" @change="getSchoolList" style="width:100%" placeholder="请选择类型">
                                    <el-option v-for="(item,index) in schoolTypeList" :label="item.name" :value="item.id" :key="index"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <template v-if="schoolList.length > 0">
                            <el-col :xs="24" :sm="12" :lg="6">
                                <el-form-item label="技能：">
                                    <el-select v-model="school_id" @change="getLevelList" style="width:100%" placeholder="请选择技能">
                                        <el-option v-for="(item,index) in schoolList" :label="item.name" :value="item.id" :key="index"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </template>
                        <template v-if="schoolLevelList.length > 0">
                            <el-col :xs="24" :sm="12" :lg="6">
                                <el-form-item label="层次：">
                                    <el-select v-model="school_level_id" @change="getSpecialtyList" style="width:100%" placeholder="请选择层次">
                                        <el-option v-for="(item,index) in schoolLevelList" :label="item.name" :value="item.id" :key="index"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </template>
                        <template v-if="schoolSpecialtyList.length > 0">
                            <el-col :xs="24" :sm="12" :lg="6">
                                <el-form-item label="专业：">
                                    <el-select v-model="school_specialty_id" @change="getClassList" style="width:100%" placeholder="请选择专业">
                                        <el-option v-for="(item,index) in schoolSpecialtyList" :label="item.name" :value="item.id" :key="index"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </template>
                        <template v-if="schoolClassList.length > 0">
                            <el-col :xs="24" :sm="12" :lg="6">
                                <el-form-item label="班别：">
                                    <el-select v-model="school_class_id" style="width:100%" placeholder="请选择班别">
                                        <el-option v-for="(item,index) in schoolClassList" :label="item.name" :value="item.id" :key="index"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </template>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="关键词：">
                                <el-input v-model="word" type="text" placeholder="姓名|证件|手机号" style="width:100%"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="开始日期：">
                                <el-date-picker v-model="start_day" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" placeholder="选择开始时间"></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="结束日期：">
                                <el-date-picker v-model="end_day" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" placeholder="选择结束时间"></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="用户ID：">
                                <el-input v-model="user_id" type="text" placeholder="请输入用户ID" style="width:100%"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="状态：">
                                <el-select v-model="status" style="width:100%" placeholder="请选择状态">
                                    <el-option label="待付款" value="1"></el-option>
                                    <el-option label="分期中" value="2"></el-option>
                                    <el-option label="已逾期" value="3"></el-option>
                                    <el-option label="已完成" value="4"></el-option>
                                    <el-option label="报名中" value="5"></el-option>
                                    <el-option label="已关闭" value="20"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :xs="24" :sm="12" :lg="6">
                            <el-form-item label="订单编号：">
                                <el-input v-model="order_number" type="text" placeholder="请输入订单编号" style="width:100%"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-row :xs="24" :sm="12" :lg="6" style="float: right; margin-right: 10px;">
                            <el-button type="success" v-if="is_admin == 1" @click="exportExcel">导出</el-button>
                            <el-button type="primary" @click="search">查询</el-button>
                            <el-button @click="reset">重置</el-button>
                        </el-row>
                    </el-row>
                </el-form>
            </div>
        </table-bar>
        <el-table :data="lists" :showPage="false" :height="550" border ref="table">
            <el-table-column label="ID" width="70" prop="id" v-if="columns[0].show"/>
            <el-table-column label="姓名" width="90" prop="id_name" v-if="columns[1].show">
                <template slot-scope="scope">
                    <el-button @click="showUseInfoDialog(scope.row)" type="success">{{ scope.row.id_name }}</el-button>
                </template>
            </el-table-column>
            <el-table-column label="证件号" width="100" prop="id_number" v-if="columns[2].show"/>
            <el-table-column label="手机号" width="100" prop="mobile" v-if="columns[3].show"/>
            <el-table-column label="城市" width="70" prop="city_name" v-if="columns[4].show"/>
            <el-table-column label="分类" width="80" prop="school_type_name" v-if="columns[5].show"/>
            <el-table-column label="技能" width="110" prop="school_name" v-if="columns[6].show"/>
            <el-table-column label="层次" width="65" prop="school_level_name" v-if="columns[7].show"/>
            <el-table-column label="专业" width="70" prop="school_specialty_name" v-if="columns[8].show"/>
            <el-table-column label="班级" width="70" prop="school_class_name" v-if="columns[9].show"/>
            <el-table-column label="状态" width="70" prop="status_name" v-if="columns[10].show"/>
            <el-table-column label="报名费" width="70" prop="enroll_price" v-if="columns[11].show"/>
            <el-table-column label="订单金额" width="80" prop="price" v-if="columns[12].show"/>
            <el-table-column label="卡券金额" width="80" prop="coupon_price" v-if="columns[13].show"/>
            <el-table-column label="实际金额" width="80" prop="total_price" v-if="columns[14].show"/>
            <el-table-column label="分期次数" width="70" prop="school_pay_many_num" v-if="columns[15].show">
                <template slot-scope="scope">
                    <template v-if="scope.row.school_pay_many_num == 0">
                        <el-tag type="success">全款</el-tag>
                    </template>
                    <template v-else>
                        <el-tag type="danger">{{ scope.row.school_pay_many_num }}</el-tag>
                    </template>
                </template>
            </el-table-column>
            <el-table-column label="首付金额" width="120" prop="first_price" v-if="columns[16].show"/>
            <el-table-column label="已支付金额" width="120" prop="pay_price" v-if="columns[17].show"/>
            <el-table-column label="分期模式" width="80" prop="enroll_type_name" v-if="columns[18].show"/>
            <el-table-column label="用户ID" width="80" prop="user_id" v-if="columns[19].show"/>
            <el-table-column label="账单日期" width="80" prop="enroll_at" v-if="columns[20].show"/>
            <el-table-column label="一起支付?" width="80" prop="is_all_pay" v-if="columns[21].show">
                <template slot-scope="scope">
                    <template v-if="scope.row.is_all_pay == 0">
                        <el-tag type="info">否</el-tag>
                    </template>
                    <template v-else>
                        <el-tag type="danger">是</el-tag>
                    </template>
                </template>
            </el-table-column>
            <el-table-column label="户籍地" width="100" prop="address" v-if="columns[22].show"/>
            <el-table-column label="现住址" width="140" prop="now_address" v-if="columns[23].show"/>
            <el-table-column label="招生站" width="80" prop="enroll_address" v-if="columns[24].show"/>
            <el-table-column label="招生老师" width="80" prop="enroll_teacher" v-if="columns[25].show">
                <template slot-scope="scope">
                    <template v-if="!!scope.row.enroll_teacher">
                        <el-button @click="showEnrollDialog(scope.row)" type="info">{{ scope.row.enroll_teacher }}</el-button>
                    </template>
                    <template v-else>
                        <el-button @click="showEnrollDialog(scope.row)" type="success">设置</el-button>
                    </template>
                </template>
            </el-table-column>
            <el-table-column label="原订单ID" width="80" prop="old_order_pay_id" v-if="columns[26].show"/>
            <el-table-column label="备注" width="180" prop="remark" v-if="columns[27].show"/>
            <el-table-column label="创建时间" width="140" prop="create_time" v-if="columns[28].show"/>
            <el-table-column fixed="right" label="操作" width="300">
                <template slot-scope="scope">
                    <template v-if="scope.row.is_close == 0 && is_admin == 1">
                        <el-button type="danger" @click="updateModel(scope.row)">修改</el-button>
                        <el-button type="success" @click="classModel(scope.row)">专业</el-button>
                        <el-button type="danger" @click="closeModel(scope.row)">关闭</el-button>
                    </template>
                    <el-button type="primary" @click="toOrderModel(scope.row)">子订单</el-button>
                </template>
            </el-table-column>
        </el-table>
        <template v-if="allpage>10">
            <el-pagination @current-change="handleCurrentChange"
                            :current-page="1"
                            :page-size="10"
                            layout="total, prev, pager, next, jumper"
                            :total="allpage">
            </el-pagination>
        </template>
        <el-dialog title="用户基本信息修改" width="25%" :visible.sync="dvUserInfoVisible" :before-close="handleClose">
            <el-form ref="model" :model="model" label-width="70px">
                <el-form-item label="姓名">
                    <el-input v-model="model.id_name" placeholder="请输入姓名" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="证件号">
                    <el-input v-model="model.id_number" placeholder="请输入证件号" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="手机号">
                    <el-input v-model="model.mobile" placeholder="请输入手机号" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input v-model="model.remark" type="textarea" :rows="4" placeholder="请输入备注" style="width:100%"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dvUserInfoVisible = false">取 消</el-button>
                <el-button type="primary" @click="onUserInfoSubmit">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="招生站设置" width="25%" :visible.sync="dvEnrollVisible" :before-close="handleClose">
            <el-form ref="model" :model="model" label-width="70px">
                <el-form-item label="招生站">
                    <el-input v-model="model.enroll_address" placeholder="请输入招生站" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="招生老师">
                    <el-input v-model="model.enroll_teacher" placeholder="请输入招生老师" style="width:100%"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dvEnrollVisible = false">取 消</el-button>
                <el-button type="primary" @click="onEnrollSubmit">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="专业修改" width="25%" :visible.sync="dvClassVisible" :before-close="handleClose">
            <el-form ref="model" :model="model" label-width="70px">
                <el-form-item label="姓名">
                    <el-input v-model="model.id_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="证件号">
                    <el-input v-model="model.id_number" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="手机号">
                    <el-input v-model="model.mobile" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="类型">
                    <el-input v-model="model.school_type_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="技能">
                    <el-input v-model="model.school_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原层次">
                    <el-input v-model="model.school_level_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原专业">
                    <el-input v-model="model.school_specialty_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原班级">
                    <el-input v-model="model.school_class_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="层次：">
                    <el-select v-model="model.new_school_level_id" @change="getSpecialtyList" style="width:100%" placeholder="请选择层次">
                        <el-option v-for="(item,index) in schoolLevelList" :label="item.name" :value="item.id" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <template v-if="schoolSpecialtyList.length > 0">
                    <el-form-item label="专业：">
                        <el-select v-model="model.new_school_specialty_id" @change="getClassList" style="width:100%" placeholder="请选择专业">
                            <el-option v-for="(item,index) in schoolSpecialtyList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="schoolClassList.length > 0">
                    <el-form-item label="班别：">
                        <el-select v-model="model.new_school_class_id" style="width:100%" placeholder="请选择班别">
                            <el-option v-for="(item,index) in schoolClassList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dvClassVisible = false">取 消</el-button>
                <el-button type="primary" @click="onClassSubmit">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="编辑" width="30%" :visible.sync="dvEditVisible" :before-close="handleClose">
            <el-form ref="model" :model="model" label-width="90px">
                <el-form-item label="姓名">
                    <el-input v-model="model.id_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="证件号">
                    <el-input v-model="model.id_number" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="手机号">
                    <el-input v-model="model.mobile" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原类型">
                    <el-input v-model="model.school_type_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原技能">
                    <el-input v-model="model.school_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原层次">
                    <el-input v-model="model.school_level_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原专业">
                    <el-input v-model="model.school_specialty_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原班级">
                    <el-input v-model="model.school_class_name" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原全款金额">
                    <el-input v-model="model.price" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="卡券金额">
                    <el-input v-model="model.coupon_price" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="原实际金额">
                    <el-input v-model="model.total_price" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="已支付金额">
                    <el-input v-model="model.pay_price" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="报考省：">
                    <el-select v-model="model.province_id" @change="getCityList" filterable style="width:100%" placeholder="报考省">
                        <el-option v-for="(item,index) in provinceList" :label="item.name" :value="item.id" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <template v-if="cityList.length > 0">
                    <el-form-item label="报考市：">
                        <el-select v-model="model.city_config_id" filterable style="width:100%" placeholder="报考市">
                            <el-option v-for="(item,index) in cityList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <el-form-item label="类型：">
                    <el-select v-model="model.new_school_type_id" @change="getSchoolList" style="width:100%" placeholder="请选择类型">
                        <el-option v-for="(item,index) in schoolTypeList" :label="item.name" :value="item.id" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <template v-if="schoolList.length > 0">
                        <el-form-item label="技能：">
                            <el-select v-model="model.new_school_id" @change="getLevelList" style="width:100%" placeholder="请选择技能">
                                <el-option v-for="(item,index) in schoolList" :label="item.name" :value="item.id" :key="index"></el-option>
                            </el-select>
                        </el-form-item>
                </template>
                <template v-if="schoolLevelList.length > 0">
                    <el-form-item label="层次：">
                        <el-select v-model="model.new_school_level_id" @change="getSpecialtyList" style="width:100%" placeholder="请选择层次">
                            <el-option v-for="(item,index) in schoolLevelList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="schoolSpecialtyList.length > 0">
                    <el-form-item label="专业：">
                        <el-select v-model="model.new_school_specialty_id" @change="getClassList" style="width:100%" placeholder="请选择专业">
                            <el-option v-for="(item,index) in schoolSpecialtyList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="schoolClassList.length > 0">
                    <el-form-item label="班别：">
                        <el-select v-model="model.new_school_class_id" @change="getNewPrice" style="width:100%" placeholder="请选择班别">
                            <el-option v-for="(item,index) in schoolClassList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="model.new_price">
                    <el-form-item label="全款金额">
                        <el-input v-model="model.new_price" :disabled="true" style="width:100%"></el-input>
                    </el-form-item>
                </template>
                <el-form-item label="户籍地">
                    <el-input v-model="model.address" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="现住址">
                    <el-input v-model="model.now_address" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="招生站">
                    <el-input v-model="model.enroll_address" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="招生老师">
                    <el-input v-model="model.enroll_teacher" :disabled="true" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input v-model="model.remark" type="textarea" :rows="4" placeholder="请输入备注" style="width:100%"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dvEditVisible = false">取 消</el-button>
                <el-button type="primary" @click="onEditSubmit">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="编辑" width="30%" :visible.sync="dvAddVisible" :before-close="handleClose">
            <el-form ref="model" :model="model" label-width="90px">
                <el-form-item label="用户ID">
                    <el-input v-model="model.user_id" type="number" placeholder="请输入用户ID"  style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="姓名">
                    <el-input v-model="model.id_name" placeholder="请输入姓名" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="证件号">
                    <el-input v-model="model.id_number" placeholder="请输入证件号" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="手机号">
                    <el-input v-model="model.mobile" placeholder="请输入手机号" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="报考省：">
                    <el-select v-model="model.province_id" @change="getCityList" filterable style="width:100%" placeholder="报考省">
                        <el-option v-for="(item,index) in provinceList" :label="item.name" :value="item.id" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <template v-if="cityList.length > 0">
                    <el-form-item label="报考市：">
                        <el-select v-model="model.city_config_id" filterable style="width:100%" placeholder="报考市">
                            <el-option v-for="(item,index) in cityList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <el-form-item label="类型：">
                    <el-select v-model="model.school_type_id" @change="getSchoolList" style="width:100%" placeholder="请选择类型">
                        <el-option v-for="(item,index) in schoolTypeList" :label="item.name" :value="item.id" :key="index"></el-option>
                    </el-select>
                </el-form-item>
                <template v-if="schoolList.length > 0">
                        <el-form-item label="技能：">
                            <el-select v-model="model.school_id" @change="getLevelList" style="width:100%" placeholder="请选择技能">
                                <el-option v-for="(item,index) in schoolList" :label="item.name" :value="item.id" :key="index"></el-option>
                            </el-select>
                        </el-form-item>
                </template>
                <template v-if="schoolLevelList.length > 0">
                    <el-form-item label="层次：">
                        <el-select v-model="model.school_level_id" @change="getSpecialtyList" style="width:100%" placeholder="请选择层次">
                            <el-option v-for="(item,index) in schoolLevelList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="schoolSpecialtyList.length > 0">
                    <el-form-item label="专业：">
                        <el-select v-model="model.school_specialty_id" @change="getClassList" style="width:100%" placeholder="请选择专业">
                            <el-option v-for="(item,index) in schoolSpecialtyList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="schoolClassList.length > 0">
                    <el-form-item label="班别：">
                        <el-select v-model="model.school_class_id" @change="getNewPrice" style="width:100%" placeholder="请选择班别">
                            <el-option v-for="(item,index) in schoolClassList" :label="item.name" :value="item.id" :key="index"></el-option>
                        </el-select>
                    </el-form-item>
                </template>
                <template v-if="model.new_price">
                    <el-form-item label="全款金额">
                        <el-input v-model="model.new_price" :disabled="true" style="width:100%"></el-input>
                    </el-form-item>
                </template>
                <el-form-item label="户籍地">
                    <el-input v-model="model.address" placeholder="请输入户籍地" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="现住址">
                    <el-input v-model="model.now_address" placeholder="请输入现住址" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="招生站">
                    <el-input v-model="model.enroll_address" placeholder="请输入招生站" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="招生老师">
                    <el-input v-model="model.enroll_teacher" placeholder="请输入招生老师" style="width:100%"></el-input>
                </el-form-item>
                <el-form-item label="备注">
                    <el-input v-model="model.remark" type="textarea" :rows="4" placeholder="请输入备注" style="width:100%"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dvAddVisible = false">取 消</el-button>
                <el-button type="primary" @click="onAddSubmit">确 定</el-button>
            </span>
        </el-dialog>
        <el-dialog title="导入EXCEL" :visible.sync="batchImportMemberVisible" width="30%">
			<el-form :model="batchImportShopMember" label-width="110px" class="demo-ruleForm">
				<el-form-item label="上传数据" >
					<el-upload
						class="upload-demo"
						:action="uploadExcel"
						accept=".xlsx"
						name="file"
						:on-success = "onSuccess"
						:on-error="onError"
                        :limit="1"
                        :on-exceed="handleExceed"
                        :file-list="fileList"
						style="display: inline-block;">
						<el-button size="small" type="primary">点击上传</el-button>
					</el-upload>
				</el-form-item>
				<el-form-item>
					<el-button @click="batchImportMemberVisible = false">取 消</el-button>
					<el-button type="primary" @click="batchImportMemberSubmit">确 定</el-button>
				</el-form-item>
			</el-form>
		</el-dialog>
    </div>
</template>

<script>
    import {getOrderCommissionList,reloadParentOrderCommission,settlementOrderCommission} from '@/api/order/orderCommissionApi';
    import {isCheckAdmin} from '@/api/admin/adminApi';
    import {getSingleSchoolTypeListAll} from '@/api/single/singleSchoolTypeApi';
    import {getLoadSchoolListAll} from '@/api/school/schoolApi';
    import {getSchoolLevelLoadListAll} from '@/api/school/schoolLevelApi';
    import {getSchoolSpecialtyLoadListAll} from '@/api/school/schoolSpecialtyApi';
    import {getLoadSchoolClassListAll} from '@/api/school/schoolClassApi';
    import {getCityConfigListAll} from '@/api/sys/cityConfigApi';
    import {baseUrl} from '@/utils/config.js';

export default {
    data() {
        return {
            lists: [],
            is_admin:0,
            schoolTypeList:[],
            provinceList:[],
            cityList:[],
            schoolList:[],
            schoolLevelList:[],
            schoolSpecialtyList:[],
            schoolClassList:[],
            allpage: 1,//总页数
            showItem: 5,//分页显示得中间按钮个数
            current: 1,//当前页
            enroll_type: '',
            province_id:'',
            city_config_id:'',
            school_type_id:'',
            school_id:'',
            school_level_id:'',
            school_specialty_id:'',
            school_class_id:'',
            word:'',
            start_day:'',
            end_day:'',
            user_id:'',
            order_number:'',
            status:'',
            model: {},
            dvUserInfoVisible: false,
            columns: [
                {name: "ID", show: true},
                {name: "姓名", show: true},
                {name: "证件", show: true},
                {name: "手机号", show: true},
                {name: "城市", show: true},
                {name: "分类", show: true},
                {name: "技能", show: true},
                {name: "层次", show: true},
                {name: "专业", show: true},
                {name: "班级", show: true},
                {name: "状态", show: true},
                {name: "报名费", show: true},
                {name: "订单金额", show: true},
                {name: "卡券金额", show: true},
                {name: "实际金额", show: true},
                {name: "分期次数", show: true},
                {name: "首付金额", show: true},
                {name: "已支付金额", show: true},
                {name: "分期模式", show: true},
                {name: "用户ID", show: true},
                {name: "账单日期", show: true},
                {name: "一起支付?", show: true},
                {name: "户籍地", show: true},
                {name: "现住址", show: true},
                {name: "招生站", show: true},
                {name: "招生老师", show: true},
                {name: "原订单ID", show: true},
                {name: "备注", show: true},
                {name: "创建时间", show: true},
            ],
            exportExcelUrl:baseUrl + '/order/exportExcel',
            dvEnrollVisible:false,
            dvClassVisible:false,
            dvEditVisible:false,
            dvAddVisible:false,
            fileList:[],
            batchImportMemberVisible:false,
            batchImportShopMember:{},
            uploadExcelAdress:''
        };
    },
    created: function () {
        this.loadButtonAuth();
        this.handleCurrentChange(1);
        this.getSchoolTypeList();
        this.getProvinceList();
    },
    methods: {
        handleExceed(files, fileList) {
            this.$message.warning(`当前限制处理表格文件为1个，本次选择了1个文件，共选择了1个文件，请选确认等待处理完成后再继续上传`);
        },
        //批量导入会员提交
        batchImportMemberSubmit:function(){
            excelUploadOrderPay({
                filepath:this.uploadExcelAdress
            }).then(res => {
                console.log(res);
                if(res.code == 1){
                    this.$message({
                        message: '数据处理成功',
                        type: 'success'
                    });
                    this.handleCurrentChange(1);
                    this.batchImportMemberVisible = false;
                }
            })
        },
        onSuccess:function(result,file){
            this.uploadExcelAdress = result.data.src;
            this.fileList = [];
            var nameArr = result.data.src.split('/');
            var arr = {
                'url': result.data.src,
                'uid': file.uid,
                'name':nameArr[nameArr.length - 1]
            };
            this.fileList.push(arr);
            this.$message({
                message: '上传成功',
                type: 'success'
            });
        },
        onError:function(err,file){
            this.$message({
                message: err,
                type: 'error'
            });
        },
        importExcel:function(){
            this.uploadExcelAdress = '';
            this.fileList = [];
            this.batchImportMemberVisible = true;
        },
        toOrderModel:function(row){
            this.$router.push({name:'orderDetail',query: {order_pay_id:row.id}})
        },
        onAddSubmit:function(){
            editOrderPay({
                user_id: this.model.user_id,
                school_specialty_id: this.model.school_specialty_id,
                school_class_id:this.model.school_class_id,
                school_level_id:this.model.school_level_id,
                city_config_id:this.model.city_config_id,
                school_id:this.model.school_id,
                school_type_id:this.model.school_type_id,
                remark:this.model.remark,
                enroll_address: this.model.enroll_address,
                enroll_teacher:this.model.enroll_teacher,
                id_name:this.model.id_name,
                id_number:this.model.id_number,
                mobile:this.model.mobile,
                address:this.model.address,
                now_address:this.model.now_address
            }).then(res => {
                if (res.code === 1) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.dvAddVisible = false;
                    this.cityList = [];
                    this.schoolList = [];
                    this.schoolLevelList = [];
                    this.schoolSpecialtyList = [];
                    this.schoolClassList = [];
                    this.handleCurrentChange(this.current);
                }
            })
        },
        showAddDialog:function(){
            this.model = {};
            this.cityList = [];
            this.schoolList = [];
            this.schoolLevelList = [];
            this.schoolSpecialtyList = [];
            this.schoolClassList = [];
            this.dvAddVisible = true;
        },
        onEditSubmit:function(){
            editNewOrderPay({
                id: this.model.id,
                new_school_specialty_id: this.model.new_school_specialty_id,
                new_school_class_id:this.model.new_school_class_id,
                new_school_level_id:this.model.new_school_level_id,
                city_config_id:this.model.city_config_id,
                new_school_id:this.model.new_school_id,
                new_school_type_id:this.model.new_school_type_id,
                remark:this.model.remark,
            }).then(res => {
                if (res.code === 1) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.dvEditVisible = false;
                    this.cityList = [];
                    this.schoolList = [];
                    this.schoolLevelList = [];
                    this.schoolSpecialtyList = [];
                    this.schoolClassList = [];
                    this.handleCurrentChange(this.current);
                }
            })
        },
        getNewPrice:function(value){
            for(var i = 0; i < this.schoolClassList.length; i++){
                if(this.schoolClassList[i].id == value){
                    this.$set(this.model,"new_price",this.schoolClassList[i].price);
                }
            }
        },
        updateModel:function(row){
            this.model = row;
            this.cityList = [];
            this.schoolList = [];
            this.schoolLevelList = [];
            this.schoolSpecialtyList = [];
            this.schoolClassList = [];
            this.dvEditVisible = true;
        },
        onClassSubmit:function(){
            updateClassOrderPay({
                id: this.model.id,
                new_school_specialty_id: this.model.new_school_specialty_id,
                new_school_class_id:this.model.new_school_class_id,
                new_school_level_id:this.model.new_school_level_id
            }).then(res => {
                if (res.code === 1) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.dvClassVisible = false;
                    this.schoolLevelList = [];
                    this.schoolSpecialtyList = [];
                    this.schoolClassList = [];
                    this.handleCurrentChange(this.current);
                }
            })
        },
        classModel:function(row){
            this.model = row;
            this.getLevelList(row.school_id);
            this.schoolSpecialtyList = [];
            this.schoolClassList = [];
            this.dvClassVisible = true;
        },
        onEnrollSubmit:function(){
            updateEnrollTeacherOrderPay({
                id: this.model.id,
                enroll_address: this.model.enroll_address,
                enroll_teacher:this.model.enroll_teacher,
            }).then(res => {
                if (res.code === 1) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.dvEnrollVisible = false;
                    this.handleCurrentChange(this.current);
                }
            })
        },
        showEnrollDialog:function(row){
            this.model = row;
            if(this.is_admin == 1){
                this.dvEnrollVisible = true;
            }
        },
        onUserInfoSubmit:function(){
            updateUserBasicOrderPay({
                id: this.model.id,
                remark: this.model.remark,
                id_name:this.model.id_name,
                id_number:this.model.id_number,
                mobile:this.model.mobile,
            }).then(res => {
                if (res.code === 1) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.dvUserInfoVisible = false;
                    this.handleCurrentChange(this.current);
                }
            })
        },
        showUseInfoDialog:function(row){
            this.model = row;
            if(this.is_admin == 1){
                this.dvUserInfoVisible = true;
            }
        },
        getSchoolTypeList:function(){
            getSingleSchoolTypeListAll().then(res => {
                this.schoolTypeList = res.data.lists;
            })
        },
        getProvinceList:function(){
            getCityConfigListAll().then(res => {
                this.provinceList = res.data.lists;
            })
        },
        getCityList:function(value){
            getCityConfigListAll({
                parent_id:value
            }).then(res => {
                this.cityList = res.data.lists;
            })
        },
        getSchoolList:function(value){
            getLoadSchoolListAll({
                school_type_id:value,
                city_config_id:this.city_config_id
            }).then(res => {
                this.schoolList = res.data.lists;
            })
        },
        getLevelList:function(value){
            getSchoolLevelLoadListAll({
                school_id:value,
            }).then(res => {
                this.schoolLevelList = res.data.lists;
            })
        },
        getSpecialtyList:function(value){
            getSchoolSpecialtyLoadListAll({
                school_level_id:value,
            }).then(res => {
                this.schoolSpecialtyList = res.data.lists;
            })
        },
        getClassList:function(value){
            getLoadSchoolClassListAll({
                school_specialty_id:value,
                is_start_enroll:2
            }).then(res => {
                this.schoolClassList = res.data.lists;
            })
        },
        loadButtonAuth: function () {
            isCheckAdmin().then(res => {
                this.is_admin = res.data.is_admin;
            })
        },
        handleCurrentChange: function (index) {
            this.current = index;
            getOrderPayList({
                page: index,
                status: this.status,
                word:this.word,
                start_day:this.start_day,
                end_day:this.end_day,
                enroll_type:this.enroll_type,
                order_number:this.order_number,
                school_type_id:this.school_type_id,
                city_config_id:this.city_config_id,
                school_level_id:this.school_level_id,
                school_id:this.school_id,
                school_specialty_id:this.school_specialty_id,
                school_class_id:this.school_class_id
            }).then(res => {
                this.lists = res.data.lists;
                this.allpage = res.data.allpage;
            })
        },
        exportExcel:function(){
            window.location.href = this.exportExcelUrl + '?word=' + this.word + '&status=' + this.status + '&start_day=' + this.start_day
             + '&end_day=' + this.end_day + '&order_number=' + this.order_number + '&school_type_id=' + this.school_type_id + '&city_config_id=' + this.city_config_id + 
             '&school_level_id=' + this.school_level_id + '&school_id=' + this.school_id + '&school_specialty_id=' + this.school_specialty_id + '&school_class_id=' + this.school_class_id;
        },
        showDialog: function () {
            this.model = {};
            this.dvEdit = true;
        },
        reset: function () {
            this.status = '';
            this.province_id = '';
            this.word = '';
            this.start_day = '';
            this.end_day = '';
            this.start_day = '';
            this.order_number = '';
            this.school_type_id = '';
            this.city_config_id = '';
            this.school_level_id = '';
            this.school_id = '';
            this.school_specialty_id = '';
            this.school_class_id = '';
            this.handleCurrentChange(1);
        },
        search: function () {
            this.handleCurrentChange(1);
        },
        handleClose: function (done) {
            this.$confirm("确认关闭？")
                .then(_ => {
                    done();
                })
                    .catch(_ => {
                });
        },
        changeColumn(columns) {
            this.columns = columns;
            this.$refs.table.doLayout()
        },
        closeModel: function (row) {
            this.$confirm("您确认要关闭该订单?", "提示", {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'info'
            }).then(() => {
                closeOrderPay({
                    id: row.id,
                }).then(res => {
                    if (res.code === 1) {
                        this.$message({
                            message: '操作成功',
                            type: 'success'
                        });
                        this.handleCurrentChange(this.current);
                    }
                })
            }).catch(() => {
            })
        },
    },
}
</script>

<style lang='scss' scoped>
.page-content {
    width: 100%;
    height: 100%;
    .avatar {
        width: 50px;
        height: 50px;
        border-radius: 50%;
    }
}

</style>

